import '@/assets/base.scss'
import { createPinia } from 'pinia'
import { createApp } from 'vue'
import { createRouter, createWebHashHistory } from 'vue-router/auto'
import routes from '~pages'
import App from './app.vue'
// @ts-ignore
import { createI18n } from 'vue-i18n'
// @ts-ignore
import zh from '../utils/lang/zh'
// @ts-ignore
import en from '../utils/lang/en'
// import messages from '@intlify/unplugin-vue-i18n/messages'
import './index.scss'

routes.push({
  path: '/',
  redirect: '/popup',
})

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes,
})
const i18n = createI18n({
  locale: 'zh',
  legacy: false,
  messages: {zh, en}
  // messages,
})
createApp(App).use(i18n).use(router).use(createPinia()).mount('#app')

console.log(router.getRoutes())

self.onerror = function (message, source, lineno, colno, error) {
  console.info(
    `Error: ${message}\nSource: ${source}\nLine: ${lineno}\nColumn: ${colno}\nError object: ${error}`
  )
}
